package org.real.guetshop.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.real.guetshop.pojo.dto.DetailDTO;
import org.real.guetshop.pojo.dto.MerchantLoginDTO;
import org.real.guetshop.pojo.entity.Store;
import org.real.guetshop.pojo.vo.StoreVO;

import java.util.List;

@Mapper
public interface MerchantMapper {

    /**
     * 根据名字查询数据
     * @return
     */
    @Select("select * from store where username = #{username}")
    Store getByName(Store store);

    /**
     * 商家注册
     * @param store
     */
    @Insert("insert into store (username, password, status,email,salt) VALUES " +
            "(#{username},#{password},#{status},#{email},#{salt})")
    void insert(Store store);

    /**
     * 根据用户名获得数据
     * @return
     */
    @Select("select * from store where username = #{username}")
    Store getByUsername(MerchantLoginDTO merchantLoginDTO);

    /**
     * 商家信息补充
     * @param detailDTO
     */
//    @Update("update store set name = #{name}, phone = #{phone}, address = #{address} where username = #{username}")
    void detail(DetailDTO detailDTO);

    /**
     * 用户获取商家列表
     * @return
     */
    @Select("select * from store order by id")
    List<StoreVO> getMerchant();

    /**
     * 商家信息修改
     * @param store
     */
    void update(Store store);

    /**
     * 商家获取信息
     * @return
     */
    @Select("select * from store where id = #{storeId}")
    StoreVO getStoreInfo(Integer storeId);
}
